Largest Olympics

Find the Olympics with the highest number of athletes. The Olympics game is a combination of the year and the season, and is found in the 'games' column. Output the Olympics along with the corresponding number of athletes.

table name:olympics_athletes_events

Solution:
select top 1   count(distinct id) as athlets,games from olympics_athletes_events
group by games order by athlets desc

Output:

SQL Script:
CREATE TABLE [dbo].[olympics_athletes_events](
[id] [int] NOT NULL,
[name] [varchar](150) NULL,
[sex] [varchar](50) NULL,
[age] [float] NULL,
[height] [float] NULL,
[weight] [float] NULL,
[team] [varchar](150) NULL,
[noc] [varchar](150) NULL,
[games] [nvarchar](150) NULL,
[year] [int] NULL,
[season] [varchar](150) NULL,
[city] [varchar](150) NULL,
[sport] [varchar](150) NULL,
[event] [varchar](150) NULL,
[medal] [varchar](150) NULL
) ON [PRIMARY]
GO

Comments (0)